home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / comm / mmgr / MM_ReqFiles.lha / MM_REQFiles.Rexx_UNCMP < prev    next >
Text File  |  1996-08-27  |  18KB  |  418 lines

  1. /*
  2.  
  3.               $VER: MM_REQFiles V0.11  (27.08.1996)
  4.  
  5.           (c) 1996 Ulrich Lammers (39:178/0.0@AmigaNet)
  6.  
  7. */
  8.  
  9.  
  10. options cache
  11. options failat 99
  12. options results
  13.  
  14. signal on break_c
  15. signal on break_d
  16. signal on break_e
  17. signal on break_f
  18. signal on halt
  19. signal on ioerr
  20. signal on syntax
  21.  
  22.  
  23.  
  24.  
  25. if ~show('P','MAILMANAGER') then do                                                                                                                                                        I='| '
  26.      say 'FEHLER : Zum korrekten Ablauf dieses Skripts, muß MailManager'
  27.      say '         betriebsbereit im Speicher liegen.'
  28.     exit 0
  29.    end
  30.  
  31. else address MAILMANAGER
  32.  
  33. parse arg in.areatag in.msgnum rest
  34.  
  35. if in.areatag = '?' then do
  36.                            say ''
  37.                            say ' Rx MM_ReqFiles[.Rexx] [ %N %A ] '
  38.                            say ''
  39.                           exit
  40.                          end
  41.  
  42.  
  43.  
  44.                              call Include_Lib('rexxsupport')
  45.                              call Init()
  46.                              call log('/')
  47.                              call log('+ *** MM_ReqFiles V0.11  started *** ')
  48.                              call log('|      (©) 1996  Ulrich Lammers      ')
  49.                              call log('|                                    ')
  50.                              call log('|  Read Config ... ')
  51.  
  52.                              call Read_Config()
  53.  
  54.                              call log('|                                    ')
  55.                              call log('|     done...')
  56.  
  57.  
  58.  
  59.            MM_Requester Titel 'REQ' 'GadGetUser'
  60.  
  61.  
  62.                                      If RC=1 then req.wahl = 1
  63.                                      If RC=2 then req.wahl = 2
  64.                                      If RC=3 then req.wahl = 3
  65.                                              End           ='B9'
  66.                                      If RC=0 then call quit(5,'Aborted by User')
  67.  
  68.  
  69.  
  70.  
  71.  
  72. if req.wahl = 1 then do
  73.                        
  74.                        MM_MultiselReq 'cfg.change.bbs' 'req.out' '"Please select Files to Request"' 'STR'
  75.                         if RC=1 then call quit(5,'Aborted by User')
  76.                         call log('|                                    ')
  77.                         if req.out.count>0 then do n=0 to req.out.count-1
  78.  
  79.                          parse var req.out.n out.name dummy out.file .
  80.  
  81.                          tmp  =         '"#?'out.name'#?'out.file'#?"'
  82.  
  83.                          MM_SearchinStem 'stem.cfgdata' 'found' tmp 'STR'
  84.  
  85.                                                dataout = found.0
  86.  
  87.  
  88.                            parse var dataout out.name out.file out.node out.passwd .
  89.  
  90.                               parse var out.node req.out.node '@' dummy
  91.  
  92.                              req = translate(Strip(req.out.node), '..', ':/')'.REQ'
  93.  
  94.                                if exists(System.Outbound||req) then req.mode = 'A'
  95.                                                                else req.mode = 'W'
  96.  
  97.                                    if ~open(req.wahl.file,system.outbound||req,req.mode) then Call quit(30,'Could not open 'System.Outbound||req'')
  98.  
  99.                                    if out.passwd = NONE then call writeLN(req.wahl.file,Strip(out.file)'')
  100.                                                         else call writeLN(req.wahl.file,Strip(out.file)' 'strip(out.passwd)'')
  101.  
  102.                                                                  call close(req.wahl.file)
  103.                                                                  call log('|  Reqfile.: 'substr(out.file,1,25,'.')' from.: 'req.out.node' ')
  104.                                                 end
  105.                      end
  106.  
  107.  
  108.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Titel_II = '" "';Text_II='Please Register MM_ReqFiles';Gad='*_Jepp|*_Noep'
  109.  
  110.  
  111. if req.wahl = 2 then do
  112.  
  113.                        if in.areatag ='' then call quit(5,'This funktion is only in the messagemenue available')
  114.  
  115.                        MM_ReadMsg  in.Areatag in.msgnum stem
  116.  
  117.  
  118.                                               parse var stem.FromAddr req.out.node '@' dummy
  119.  
  120.                          req = translate(Strip(req.out.node), '..', ':/')'.REQ'
  121.  
  122.                         if RC~=0 & in.msgnum = '' then call quit(30,'could not read filelist ( Msg 'in.msgnum ' in Area 'in.areatag' )')
  123.  
  124.                          do n=0 to stem.text.count
  125.  
  126.                                                      file = stem.text.n
  127.  
  128.  
  129.                             MM_AddtoStem 'out.stem' 'file'
  130.  
  131.                          end
  132.  
  133.  
  134.                          MM_MultiselReq 'out.stem' 'req.out' '"Please select Files to Request"'  'STR'
  135.  
  136.                           if RC=1 then call quit(5,'Aborted by User')
  137.  
  138.                           if exists(System.Outbound||req) then req.mode = 'A'
  139.                                                           else req.mode = 'W'
  140.  
  141.                           if ~open(req.wahl.file,system.outbound||req,req.mode) then Call quit(30,'Could not open 'System.Outbound||req'')
  142.  
  143.                               call log('|                                    ')
  144.  
  145.                               if req.out.count>0 then do n=0 to req.out.count-1
  146.  
  147.                                                         parse var req.out.n select.files dummy
  148.  
  149.                                                         call writeLN(req.wahl.file,Strip(select.files)'')
  150.                                                         call log('|  Reqfile.: 'substr(select.files,1,25,'.')' from.: 'req.out.node' ')
  151.                                                       end
  152.  
  153.                            call close(req.wahl.file)
  154.                      end
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162. if req.wahl = 3 then do
  163.  
  164.                       MM_SingleSelReq 'cfg.bbs' 'out.name' '"Please select a Filelist"' 'STR'
  165.  
  166.                       if RC=1 then call quit(5,'Aborted by User')
  167.  
  168.                       bbs.name = strip(out.name.0)
  169.  
  170.                       tmp  =                     '#?'bbs.name'#?'
  171.  
  172.  
  173.  
  174.                          MM_SearchinStem 'stem.data' 'found' tmp 'STR'
  175.  
  176.                          dataout = found.0
  177.  
  178.  
  179.                            parse var dataout out.name out.node out.passwd out.pfad .
  180.  
  181.                               name    = strip(out.name)
  182.                               node    = strip(out.node)
  183.                               passwd  = strip(out.passwd)
  184.                               pfad    = strip(out.pfad)
  185.  
  186.                               parse var node req.out.node '@' dummy
  187.  
  188.  
  189.                       MM_ReadStem pfad 'stem.out.liste'
  190.  
  191.                        if RC~=0 then call quit(30,'could not read 'pfad'')
  192.  
  193.                         MM_MultiSelReq 'stem.out.liste' 'ausw' '"Please select files to request"' 'STR'
  194.  
  195.                          if RC=1 then call quit(5,'Aborted by User')
  196.  
  197.                        req = translate(req.out.node,'..',':/')'.REQ'
  198.  
  199.  
  200.                        if exists(System.Outbound||req) then req.mode = 'A'
  201.                                                        else req.mode = 'W'
  202.                               call log('|                                    ')
  203.  
  204.                       if ~open(outfiles,system.outbound||req,req.mode) then Call quit(30,'Could not open 'System.Outbound||req'')
  205.  
  206.                              if ausw.count>0 then do n=0 to ausw.count-1
  207.  
  208.                                                              write.files = ausw.n
  209.  
  210.  
  211.                                                              parse var write.files writefiles dummy
  212.  
  213.                                                              if passwd = NONE then call writeLN(outfiles,strip(writefiles)'')
  214.                                                                               else call writeLN(outfiles,strip(writefiles)' 'passwd'')
  215.                                                                                    call log('|  Reqfile.: 'substr(writefiles,1,25,'.')' from.: 'req.out.node' ')
  216.  
  217.                                                       end
  218.  
  219.                                            call close(outfiles)
  220.                      end
  221.  
  222.                                             
  223.                                                                                                                                                                                                                                                                                                                                                                              Magna='0';Call K.Init()
  224.  
  225.                                                                  if Magna = 0 then do
  226.                                                                                      MM_Requester Titel_II 'Text_II' 'Gad'
  227.                                                                                      If RC=1 then If exists('MM:Rexx/Reg_ReqFiles.Rexx') then
  228.                                                                                      Address command 'rx MM:Rexx/Reg_ReqFiles'
  229.                                                                                else call quit(10,'Could not open MM:Rexx/Reg_ReqFiles.Rexx')
  230.                                                                                      If RC=0 then Exit
  231.                                                                                    end
  232.                                             call log('|                                ')
  233.                                             call log('+  ** MM_ReqFiles V0.11 ended ** ')
  234.                                             call log('\ ')
  235.  
  236.  
  237. exit
  238.  
  239.  
  240.  
  241.  
  242.  
  243. Init: Procedur
  244.  
  245. show
  246.  
  247. ReQ                     =   '    Please select a Filerequest - Mode   '
  248. Titel                   =   '"MM_ReqFiles V0.11  (c) 1996 Ulrich Lammers"'
  249. GadGetUser              =   '  _Config REQ  |  _Message REQ  |  _Filelist REQ  |  _Abbruch  '
  250.  
  251. MM_GetCfgPaths System
  252.  
  253. MM.Loglevel             =   '2'
  254. cfg.path                =   'MM:Config/'
  255. req.wahl                =   '9'
  256. req.mode                =   'W'
  257. return
  258.  
  259.  
  260.  
  261.  
  262.  Log: procedure expose MM.
  263.  
  264. parse arg msglog
  265.  
  266. MM_WriteLog 'msglog' MM.LogLevel
  267.  
  268. return
  269.  
  270.  
  271.  
  272. Read_Config: procedur
  273.    ProgCFG   = 'MM:Config/MM_REQFiles.Cfg'
  274.    MM_ReadStem ProgCFG 'cfg'
  275.     ReadCFGError=' +  Unable to read MM_REQFFile.cfg !!!'
  276.      if RC~=0 then MM_Writelog 'ReadCFGError' '1'
  277.  
  278. do l=0 to cfg.count-1
  279.  
  280.    parse value strip(translate(cfg.l, ' ', '9'x)) with key args ';' .
  281.    key             = upper(strip(key))
  282.    args    = strip(args)
  283.  
  284.    select
  285.           when key=''                   then interate
  286.  
  287.           when key='#CONFIGREQ'         then do
  288.                                               MM_AddToStem 'stem.cfgdata' 'args'
  289.                                               parse var args st.cfg st.name parameter
  290.                                               input.cfg = substr(st.cfg' ',1,30,'.')'File.:>  'st.name
  291.                                               MM_AddToStem 'cfg.change.bbs' 'input.cfg'
  292.                                              end
  293.  
  294.           when key='#FILELIST'          then do
  295.                                               MM_AddToStem 'stem.data' 'args'
  296.                                               parse var args cfg.name cfg.parameter
  297.                                               MM_AddToStem 'cfg.bbs' 'cfg.name'
  298.                                              end
  299.           otherwise NOP
  300.         end
  301.        end
  302.  
  303. return
  304.                                                                                                                                                                                                                                                                                                                                                                             K.INIT: procedur
  305.                                                                                                                                                                                                                                                                                                                                                                                    Magna = '0'
  306.                                                                                                                                                                                                                                                                                                                                                                                    w.k='K';w.e='e';w.y='y'
  307.                                                                                                                                                                                                                                                                                                                                                                                    if exists('MM:Config/MM_ReqFiles.'||w.k||w.e||w.y) then do
  308.                                                                                                                                                                                                                                                                                                                                                                                    open(user.in,'MM:Config/MM_ReqFiles.'||w.k||w.e||w.y,'R')
  309.                                                                                                                                                                                                                                                                                                                                                                                    If INDEX(user.in,end)>=0 then Magna = '1'
  310.                                                                                                                                                                                                                                                                                                                                                                                    Call close(user.in)
  311.                                                                                                                                                                                                                                                                                                                                                                                    end
  312.                                                                                                                                                                                                                                                                                                                                                                              return
  313. Quit:
  314.  
  315.         parse arg return_code, error_msg
  316.  
  317.         error_line    = 0
  318.         rc                                              = 0
  319. signal Exit
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328. Syntax:
  329.  
  330.         signal off syntax
  331.  
  332.         return_code             = 40
  333.         error_line    = sigl
  334.         error_msg                       = 'Syntax-error' rc 'at line' sigl '['errortext(rc)']'
  335.         rc                                              = 0
  336. signal Exit
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345. break_c:; break_d:; break_e:; break_f:; halt:
  346.  
  347.         signal off break_c
  348.         signal off break_d
  349.         signal off break_e
  350.         signal off break_f
  351.         signal off halt
  352.  
  353.         return_code             =       5
  354.         error_line    = 0
  355.         error_msg                       = 'Execution halted!!!'
  356.         rc                                              = 0
  357. signal Exit
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365. Exit:
  366.  
  367.         select
  368.                 when return_code>=40 then error = 'INTERNAL-ERROR:'
  369.                 when return_code>=30 then error = 'IO-ERROR:'
  370.                 when return_code>=20 then error = 'ERROR:'
  371.                 when return_code>=10 then error = 'WARNING:'
  372.                 when return_code>=5  then error = 'INFO:'
  373.                 otherwise                                                                       error = ''
  374.         end
  375.  
  376.   call Log()
  377.         call Log('***' strip(error error_msg) '***', '+')
  378.         call Log(,'\')
  379.  
  380.  
  381. exit return_code
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389. IOerr:
  390.  
  391.         signal off ioerr
  392.  
  393.         return_code             = 20
  394.         error_line    = sigl
  395.         error_msg                       = 'IO-error' rc 'at line' sigl '['errortext(rc)']')
  396.         rc                                              = 0
  397. signal Exit
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407. Include_Lib: procedure Expose system.
  408.  
  409.         parse arg lib, prio
  410.         if right(upper(lib), 8)~='.LIBRARY' then lib    = lib'.library'
  411.         if prio=''                                                                                                      then prio       = 0
  412.  
  413.         if ~exists('libs:'lib)                then call Quit(30, '"'lib'" does not exist!')
  414.         if ~show('l', lib) then
  415.                 if ~addlib(lib, prio, -30, 0) then call Quit(20, 'Could not open "'lib'"!')
  416.  
  417. return
  418.